#ifndef BFSGRAPHTRAVERSALALGORITHM_H_
#define BFSGRAPHTRAVERSALALGORITHM_H_

#include "IGraphAlgorithm.h"

#include <sstream>

#include <boost/bind.hpp>

#include "graph_support/impls/vector/VectorGraph.h"
#include "graph_support/alg/traversal/GrTraversalBFS.h"

namespace native_orbitor
{

template< typename GraphT >
class BFSGraphTraversalAlgorithm : public IGraphAlgorithm
{
private:
	typedef GraphT Graph;
	typedef BFSGraphTraversalAlgorithm< Graph > MyT;
	typedef typename Graph::GrVertex GrVertex;
	typedef typename Graph::GrEdge GrEdge;
	typedef typename Graph::GrEdgePtr GrEdgePtr;

public:
	virtual bool isApplicable2graph( GRAPH_SUPPORT_NS::Graph * abstractGraphPtr )
	{
		Graph * graphPtr = dynamic_cast< Graph * >( abstractGraphPtr );
		return graphPtr != NULL;
	}

	virtual void runOnGraph( GRAPH_SUPPORT_NS::Graph * abstractGraphPtr )
	{
		using namespace GRAPH_SUPPORT_NS::alg::traversal;

		assert( isApplicable2graph( abstractGraphPtr ) );

		Graph * graphPtr = dynamic_cast< Graph * >( abstractGraphPtr );
		Graph & graph = * graphPtr;

		GrTraversalBFSAllEdges( graph, 0, MyT::nop );
	}

private:
	static void nop( const GrEdgePtr & walkEdge )
	{
	}
};

}

#endif /* BFSGRAPHTRAVERSALALGORITHM_H_ */
